import os
import urllib

CONFIG_NAME = 'development'


class BaseConfig(object):
    SECRET_KEY = 'ny_microdrama'
    # BASE_DOMAIN = 'http://127.0.0.1:5002'
    # COMPANY_INDEX_PER_PAGE = 20
    # COMPANY_DETAIL_PER_PAGE = 10
    # LIST_PER_PAGE = 15


class DevelopmentConfig(BaseConfig):
    DEBUG = True
    encoded_password = urllib.parse.quote('wanglei@123')
    SQLALCHEMY_DATABASE_URI = f'mysql://root:{encoded_password}@localhost:3306/micro_drama_system?charset=utf8'
    SQLALCHEMY_POOL_TIMEOUT = 15
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # SQLALCHEMY_ECHO = True

    VIDEO_UPLOAD_FOLDER = 'uploads/videos'

    OSS_CONFIG = {
        'access_key_id': 'LTAI5tByfqXh7xdjXGk3sb6A',
        'access_key_secret': 'gFdKv3vDem1bP4ulwNw24ZkSGRFl5l',
        'endpoint': 'oss.kuwan8.com',
        'bucket_name': 'micro-drama-ny',
        'region': 'cn-shanghai',
        'domain': 'oss.kuwan8.com',
        'expires': 604800,
        'image_folder': 'image_library',
        'video_folder': 'video_library'
    }

    # ACCESSKEY_ID = 'LTAI5tByfqXh7xdjXGk3sb6A'
    # ACCESSKEY_SECRET = 'gFdKv3vDem1bP4ulwNw24ZkSGRFl5l'

    # UPLOADED_SIZE = 300 * 1024
    # UPLOADED_RESUME_ALLOW = IMAGES
    # UPLOADED_RESUME_DEST = os.path.join(os.getcwd(), 'static', 'resume')
    # UPLOADED_LOGO_ALLOW = IMAGES
    # UPLOADED_LOGO_DEST = os.path.join(os.getcwd(), 'static', 'logo')

    # # celery配置
    # CELERY_BROKER_URL = 'redis://localhost:6379/0'
    # CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'


    # 确保上传目录存在
    os.makedirs(VIDEO_UPLOAD_FOLDER, exist_ok=True)


class ProductionConfig(BaseConfig):
    pass


configs = {
    'development': DevelopmentConfig,
    'production': ProductionConfig
}

config_settings = configs.get(CONFIG_NAME)
